home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / mslang / ssetup / setup.cp_ / SETUP.CPP
Encoding:
C/C++ Source or Header  |  1994-04-09  |  64.2 KB  |  1,457 lines

  1. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2. //
  3. //                SETUP.CPP
  4. //                Main file for "MAIN.EXE" Setup Studio sample program
  5. //                Use with CSETUP.DLL release 2.2.
  6. //
  7. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  8. //
  9. //                This file requires Microsoft Visual C++ Compiler and MFC 2.0 Library.
  10. //                Warning: You use this product at your own risk! You are responsible for making suitable backups in case it screws up. 
  11. //                You can use this file as a template and you can redistribute programs using this file ( Anyway, distributing
  12. //                this source code file without the full Unregistered Evaluation Copy of Setup Studio is forbidden ).
  13. //
  14. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  15. //
  16. //                There are 5 classes in this file:
  17. //
  18. //                        CSetupApp:        The application management 
  19. //                        CFirst:                  A splash dialog box with initialisation management
  20. //                        CMain:                The main application window which calls dialog boxes and GoSetup function
  21. //                        CChoice1:          To choose path and language
  22. //                        CChoice2:          To choose files to install
  23. //
  24. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  25. //                Remark:
  26. //              nPanelBold... specify italic mode ( not the bold mode ! )
  27. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  28.  
  29.  
  30.  
  31.             // ----------------------------------------------------------
  32.             //  Private messages
  33.             // ----------------------------------------------------------
  34.             #define PM_FIRST        WM_USER + 0x048                // Message for CFirst Box to start the SetupInitialize
  35.             #define IDCHANGEPATH    36                                    // EndDialog value when user want to change the path on Choice2 box
  36.             
  37.             
  38.             // ----------------------------------------------------------
  39.             //  Include files
  40.             // ----------------------------------------------------------
  41.             #include "stdafx.h"
  42.             #include <stdlib.h>
  43.             #include <direct.h>
  44.             #include "setup.h"
  45.             #include <csetup.h>
  46.             #include <ctl3d.h>
  47.             
  48.             // ----------------------------------------------------------
  49.             //  Local functions
  50.             // ----------------------------------------------------------
  51.             BOOL ExtractParameter( LPSTR szCommandLine, LPSTR szBuffer, int position );    // C programmers can use this function to retrieve Command Line parameters
  52.                 
  53.             
  54.             
  55.             #ifdef _DEBUG
  56.             #undef THIS_FILE
  57.             static char BASED_CODE THIS_FILE[] = __FILE__;
  58.             #endif
  59.             
  60.             // ----------------------------------------------------------
  61.             //  Local variables
  62.             // ----------------------------------------------------------
  63.                 BOOL bIsSetupOK;                        // Result of SetupInitialize Function
  64.                 int iLanguage;                               // Language ( french or English )
  65.                 CString UserPath;                            // Destination path
  66.                 int iType;                                         // User configuration = TYPE_VB, TYPE_TCW, TYPE_MFC or TYPE_NONE
  67.                 long UserConfigSize;                            // The size of the user' s selection
  68.                 static char szOriginalPath[160];             // First command line argument
  69.                 static char szTempSetupPath[160];        // Second command line argument
  70.             
  71.             // ----------------------------------------------------------
  72.             //  Local constants
  73.             // ----------------------------------------------------------
  74.                 #define TYPE_VB                0              // Indicate Best path for VB users
  75.                 #define TYPE_TCW          1                // Indicate Best path for TCW users
  76.                 #define TYPE_MFC          2                // Indicate Best path for MFC users
  77.                 #define TYPE_NONE          3                // Normal path must be used
  78.             
  79.  
  80.  
  81.  
  82.  
  83. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  84. //                                                                         I try to make a generic Setup Application...                                                                                              ///
  85. //                                                           This program can have up to 15 checkboxes and each checkbox is                                                                  ///
  86. ///                                                                associated with a section. This program performs basic operations                                                                 //
  87. //                                                                like section management, icons installation, winfile association                                                                      //
  88. //                                                                                and can run an EXE or an HLP file.                                                                                                    //
  89. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  90.         
  91.         
  92.         // ----------------------- General settings ------------------------------------
  93.         const CString     szYourName                 = "TEST";                              // Put your <szYourName> password here, or TEST if you are not registered
  94.         const CString    szYourPassword           = "";               // Put your <szPassword> here or nothing if you are not registered
  95.         const int             iBackgroundPaper     = BROSSE_3DCIRCLE;     // Choose the brush to use as the background paper, ( BROSSE_* )
  96.         const BOOL      bBeepMode                = TRUE;                               // True if you want the BEEP mode, FALSE if not
  97.         const BOOL        bVerifyMode                 = TRUE;                            // True if you want the VERIFY mode, FALSE if not
  98.         const CString    szProductName           = "Setup Studio";             // Name of your works
  99.         const CString   szSetupBoxTitle         = "Setup Studio Installation";    // Title of the Copy Dialog Box
  100.         
  101.         // ----------------------- General interface settings ------------------------------------
  102.         const CString        Dialog1Title            = "Setup Studio 2.2 (c)";        // Dialog box title for the path and other dialog boxes
  103.         const CString        Dialog2Title            = "Setup Studio 2.2 (c) - Installation";        // Dialog box title for the option dialog box
  104.         const CString        Dialog3Title            = "Setup Studio 2.2 (c) - Installation";        // Dialog box title for the copy dialog box
  105.         
  106.         // ----------------------- Interface settings [PANEL1] ( first panel )------------------------------------
  107.         const int                iPanel1Bitmap             = 0;                                    // Bitmap ID for Panel 1 or 0 to disable it
  108.         const CString        szPanel1Title               = "Setup Studio 2.2";        // Panel 1 title or a blank string to disable it
  109.         const CString        szPanel1TitleFont          = "Arial";                            // Panel 1 title font to use
  110.         const int                 iPanel1TitleSize          = 52;                                   // Panel 1 title font size to use
  111.         const COLORREF lPanel1TitleColor       = RGB(192,192,192);               // Panel 1 title color to use
  112.         const BOOL            bPanel1Title3D            = TRUE;                                // Panel 1 title 3D or not
  113.         const BOOL            bPanel1TitleBold       = TRUE;                               // Panel 1 title bold or not
  114.         const CString        szPanel1Detail               = "The Windows Setup programs maker";       // Panel 1 detail or a blank string to disable it
  115.         const CString        szPanel1DetailFont          = "Times New Roman";                            // Panel 1 detail font to use
  116.         const int                 iPanel1DetailSize          = 28;                                   // Panel 1 detail font size to use
  117.         const COLORREF lPanel1DetailColor       = RGB(0,128,128);               // Panel 1 detail color to use
  118.         const BOOL            bPanel1Detail3D            = TRUE;                                // Panel 1 detail 3D or not
  119.         const BOOL            bPanel1DetailBold       = TRUE;                               // Panel 1 detail bold or not
  120.         
  121.         // ----------------------- Interface settings [PANEL2] ( user selects files to install )------------------------------------
  122.         const int                iPanel2Bitmap             = IDB_SETUP2;                                    // Bitmap ID for Panel 2 or 0 to disable it
  123.         const CString        szPanel2Title               = "Setup Studio 2.2";        // Panel 2 title or a blank string to disable it
  124.         const CString        szPanel2TitleFont          = "Arial";                            // Panel 2 title font to use
  125.         const int                 iPanel2TitleSize          = 52;                                   // Panel 2 title font size to use
  126.         const COLORREF lPanel2TitleColor       = RGB(192,192,192);               // Panel 2 title color to use
  127.         const BOOL            bPanel2Title3D            = TRUE;                                // Panel 2 title 3D or not
  128.         const BOOL            bPanel2TitleBold       = TRUE;                               // Panel 2 title bold or not
  129.         const CString        szPanel2Detail               = "Setup Studio 2.2";       // Panel 2 detail or a blank string to disable it
  130.         const CString        szPanel2DetailFont          = "Arial";                            // Panel 2 detail font to use
  131.         const int                 iPanel2DetailSize          = 24;                                   // Panel 2 detail font size to use
  132.         const COLORREF lPanel2DetailColor       = RGB(192,192,192);               // Panel 2 detail color to use
  133.         const BOOL            bPanel2Detail3D            = TRUE;                                // Panel 2 detail 3D or not
  134.         const BOOL            bPanel2DetailBold       = TRUE;                               // Panel 2 detail bold or not
  135.             
  136.         // ----------------------- Interface settings [PANEL3] ( files transfert )------------------------------------
  137.         const int                iPanel3Bitmap             = 0;                                    // Bitmap ID for Panel 3 or 0 to disable it
  138.         const CString        szPanel3Title               = "Setup Studio 2.2";        // Panel 3 title or a blank string to disable it
  139.         const CString        szPanel3TitleFont          = "Arial";                            // Panel 3 title font to use
  140.         const int                 iPanel3TitleSize          = 52;                                   // Panel 3 title font size to use
  141.         const COLORREF lPanel3TitleColor       = RGB(255,0,0);               // Panel 3 title color to use
  142.         const BOOL            bPanel3Title3D            = TRUE;                                // Panel 3 title 3D or not
  143.         const BOOL            bPanel3TitleBold       = TRUE;                               // Panel 3 title bold or not
  144.         const CString        szPanel3Detail               = "[] Just 3 functions required,\n[] No need to learn another language,\n[] Up to 1200 files, 30 diskettes, 40 groups,\n[] Built in ZIP support,\n[] Files larger than a media supported,\
  145. \n[] Files date checking, automatic backup,\n[] Shared DLLs and VBX support,\n[] Multi projects management, \n[] Files are automatically renamed,\n[] SDK Setup Toolkit compatability,\
  146. \n[] French and English mode,\n[] All tools are integrated and provided,\n[] And much much more...";       // Panel 3 detail or a blank string to disable it
  147.         const CString        szPanel3DetailFont          = "Arial";                            // Panel 3 detail font to use
  148.         const int                 iPanel3DetailSize          = 22;                                   // Panel 3 detail font size to use
  149.         const COLORREF lPanel3DetailColor       = RGB(0,0,128);               // Panel 3 detail color to use
  150.         const BOOL            bPanel3Detail3D            = TRUE;                                // Panel 3 detail 3D or not
  151.         const BOOL            bPanel3DetailBold       = FALSE;                               // Panel 3 detail bold or not
  152.         
  153.         // ----------------------- Shared files settings ------------------------------------
  154.         const BOOL         bUseSharedBatch     = FALSE;                // Set this to TRUE if you wish to use the shared batch mode
  155.         const CString     szBatchFile                = "";                           // Dir and Name for the batch file, default = SYSSETUP.TMP\\SYSSETUP.BAT
  156.         const CString     szBatchDir                   = "";                       //  Temporary dir for shared files, default = SYSSETUP.TMP with final slash
  157.         
  158.         // ----------------------- LOG file settings ------------------------------------
  159.         const BOOL        bUseLogFile                = TRUE;                     // TRUE if you wish to use a LOG file, FALSE if not.
  160.         const CString    szLogFileName          = "SETUP.LOG";    //  Log file name ( without dir specification )
  161.         
  162.         // ----------------------- SECTIONS management ------------------------------------                                            
  163.         //    1 Section is associated to 1 checkbox
  164.         typedef struct sSectionEntry{
  165.             unsigned        bSelected : 1;                                        // ---> TRUE if the user selects this section, FALSE if not
  166.             long                lSize;                                                    // ---> Section Size ( in bytes )
  167.             CString              Name;                                                    // ---> Section name ( from SETUP.INF )
  168.             CString              Directory;                                            // ---> Destination relative directory for the section ( DIRX\\ for example )
  169.             CString              ELabel;                                                // ---> English label for the section ( will be associated with a CHECKBOX )
  170.             CString              FLabel;                                                 // ---> French Label for the section ( will be associated with a CHECKBOX )
  171.             }SSECTIONENTRY;              
  172.         
  173.         const int NumberOfSections = 6;                                      // From 1 to 8 sections ( and checkboxes )    
  174.         SSECTIONENTRY far Section[ NumberOfSections];
  175.         
  176.         //     Now it' s depend of your INF File: You must create section entries for all checkboxes you want and 
  177.         //    you must respect the diskettes order if your setup program contains more than 1 diskette:
  178.         //    See InitInstance for Implementation
  179.         
  180.         // ----------------------- Icons management ------------------------------------                                            
  181.         const BOOL        bInstallIcons = TRUE;                        // Install icons if section 0 is selected
  182.         typedef struct sIconEntry 
  183.             {
  184.             CString        szIconRelativeName;                             // Program name for specified icon  ( CTL3D\\SSTUDIO.EXE for example )
  185.             CString     EGroupName;                                        // Group Name ( english )
  186.             CString        EIconName;                                          // Icon title ( english )
  187.             CString        EIconText;                                            // Icon description ( english ) --> "" to add this icon without any dialog box
  188.             CString     FGroupName;                                        // Group Name ( french )
  189.             CString        FIconName;                                          // Icon title ( french )
  190.             CString        FIconText;                                            // Icon description ( french )
  191.             }ICONENTRY;
  192.                          
  193.         const int NumberOfIcons     = 2;                              // How many icons
  194.         ICONENTRY far IconEntry[NumberOfIcons];
  195.         //    See InitInstance for Implementation
  196.                         
  197.         // ----------------------- Association management ------------------------------------                                            
  198.         const BOOL bMakeAssociation = TRUE;                    // TRUE if you wish to create or change WinFile associations
  199.         typedef struct sWFAsso
  200.             {
  201.             CString        szProgName;                                        // EXE file name ( with the relative path if any )
  202.             CString        szExt;                                                   // File extension to create ( TXT, DOC ... )
  203.             }SWFASSO;
  204.         
  205.         const int NumberOfAsso = 1;                                      // Set the number of associations to create
  206.         SWFASSO    far WFAsso[ NumberOfAsso];
  207.         //    See InitInstance for Implementation
  208.         
  209.         // ----------------------- Last step: we launch something ------------------------------------                                            
  210.         const CString szLaunch     = "SSTUDIO.HLP";            // Give a HLP or an EXE, COM, PIF, BAT file to launch when the setup is ok
  211.  
  212.  
  213.  
  214.  
  215. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  216. //                                                                                        End of generic declarations.                                                                                                    //
  217. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  218.  
  219.  
  220.  
  221.  
  222. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  223. //                                                                        Implementation - Specific ( so change this )                                                                                            //
  224. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  225.  
  226.             // ----------------------------------------------------------
  227.             //  Constructor
  228.             // ----------------------------------------------------------
  229.             CSetupApp::CSetupApp()
  230.             {       
  231.             //     Now it' s depend of your INF File: You must create section entries for all checkboxes you want and 
  232.             //    you must respect the diskettes order if your setup program contains more than 1 diskette:
  233.             Section[0].Name = "CSetup";            // no directory specification because we use the main destination directory
  234.             Section[0].ELabel = "&Setup Studio 2.2";
  235.             Section[0].FLabel = "&Setup Studio 2.2";
  236.             
  237.             Section[1].Name = "Basic";
  238.             Section[1].ELabel = "&Basic header file";
  239.             Section[1].FLabel = "Fichier include en &basic";
  240.             
  241.             Section[2].Name = "Help";
  242.             Section[2].ELabel = "&Help file";
  243.             Section[2].FLabel = "&Documentation";
  244.             
  245.             Section[3].Name = "Wizard";
  246.             Section[3].ELabel = "Setup Studio &Wizard";
  247.             Section[3].FLabel = "&Assistant";
  248.             
  249.             Section[4].Name = "CTL3D";
  250.             Section[4].Directory = "CTL3D\\";
  251.             Section[4].ELabel = "CTL &3D API";
  252.             Section[4].FLabel = "API CTL &3D";
  253.             
  254.             Section[5].Name = "Demo";
  255.             Section[5].Directory = "SAMPLE\\";
  256.             Section[5].ELabel = "Sample &program";
  257.             Section[5].FLabel = "&Exemple";
  258.                 
  259.             IconEntry[0].szIconRelativeName = "SSTUDIO.EXE";    // Icon name ( will be transformed into UserPath + Name )
  260.             IconEntry[0].EGroupName = "Setup Studio 2.2";
  261.             IconEntry[0].EIconName = "Setup Studio Wizard";
  262.             IconEntry[0].EIconText = "Setup Studio Wizard is an utility program to manage files and to create diskettes sets. This new release integrates ZIP support and a files manager.";
  263.             IconEntry[0].FGroupName = "Setup Studio 2.2";
  264.             IconEntry[0].FIconName = "Assistant Setup Studio";
  265.             IconEntry[0].FIconText = "Le Wizard est un assistant pour gΘrer les fichiers et crΘer les disquettes du programme. Cette nouvelle version supporte les fichiers ZIP et intΘgre un gestionnaire de fichiers.";
  266.             
  267.             IconEntry[1].szIconRelativeName = "SSTUDIO.HLP";    // Icon name ( will be transformed into UserPath + Name )
  268.             IconEntry[1].EGroupName = "Setup Studio 2.2";
  269.             IconEntry[1].EIconName = "Setup Studio Help";
  270.             IconEntry[1].EIconText = "This 140 pages help file contains all necessary informations to build setup programs and to use Setup Studio functions.";
  271.             IconEntry[1].FGroupName = "Setup Studio 2.2";
  272.             IconEntry[1].FIconName ="Aide Setup Studio";
  273.             IconEntry[1].FIconText = "Ce fichier d' aide de 140 pages ( en franτais ) contient toutes les informations nΘcessaires pour crΘer des programmes d' installation et pour utiliser les fonctions de Setup Studio.";
  274.                    
  275.             WFAsso[0].szProgName = "SSTUDIO.EXE";
  276.             WFAsso[0].szExt = "CFG";
  277.             }
  278.         
  279.  
  280.             // ----------------------------------------------------------
  281.             //  WM_INITDIALOG
  282.             //  Guess the best path for user
  283.             // ----------------------------------------------------------
  284.             BOOL CChoice1::OnInitDialog()
  285.                 {
  286.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  287.                 CDialog::OnInitDialog();
  288.                 CString TempVBPath;
  289.                 register int i=0;
  290.                 SetWindowText( Dialog2Title );
  291.                 // We change the font weight
  292.                 if ((hfontDlg = (HFONT) SendMessage(WM_GETFONT) )) 
  293.                     {
  294.                     if (::GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont)) 
  295.                         {
  296.                         lFont.lfWeight = FW_NORMAL;
  297.                         if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont)) 
  298.                             {
  299.                             SendDlgItemMessage( IDC_EDITSRCPATH, WM_SETFONT, (WPARAM) hfontDlg, 0);
  300.                             SendDlgItemMessage( IDC_GROUPLANGUAGE, WM_SETFONT, (WPARAM) hfontDlg, 0);
  301.                             SendDlgItemMessage( IDC_RADIOENGLISH, WM_SETFONT, (WPARAM) hfontDlg, 0);
  302.                             SendDlgItemMessage( IDC_RADIOFRENCH, WM_SETFONT, (WPARAM) hfontDlg, 0);
  303.                             SendDlgItemMessage( IDC_TEXTE, WM_SETFONT, (WPARAM) hfontDlg, 0);
  304.                             }
  305.                         }
  306.                     }
  307.                 SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) );
  308.                 Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL );                              
  309.                 CenterDialogBox( m_hWnd );
  310.                 CString ProductName;
  311.                 ProductName = ( iLanguage == LANGUAGE_FRENCH )? "Indiquer le rΘpertoire ou vous souhaitez installer ": "Please, give the directory in which you want to install ";
  312.                 ProductName += szProductName;
  313.                 ProductName += ( iLanguage == LANGUAGE_FRENCH )?" et cliquer sur OK:":" and click on OK";
  314.                 CheckRadioButton( IDC_RADIOENGLISH, IDC_RADIOFRENCH, ( iLanguage == LANGUAGE_FRENCH )?IDC_RADIOFRENCH: IDC_RADIOENGLISH );
  315.                 SetDlgItemText( IDC_GROUPLANGUAGE, ( iLanguage == LANGUAGE_FRENCH )? "Votre langage " : "Your language ");
  316.                 SetDlgItemText( IDC_TEXTE, ProductName );
  317.                 SetDlgItemText( IDCANCEL, ( iLanguage == LANGUAGE_FRENCH )?"&Abandonner":"&Abort");
  318.                 /////////////////////////////////////////////////////////// Specific //////////////////////////////////////////////////////////////////////
  319.                 if ( UserPath.GetLength() > 0 )
  320.                     SetDlgItemText( IDC_EDITSRCPATH, UserPath );
  321.                 else
  322.                     {
  323.                     if ( DoesFileExist( "VB.INI", FALSE) )
  324.                         {
  325.                         TempVBPath = GetWinFileAssociation( "FRM" ) ;
  326.                         if ( TempVBPath.GetLength() > 0 )
  327.                             {
  328.                             TempVBPath =  TempVBPath.Left( TempVBPath.GetLength() - 5 ); // kill VB.EXE
  329.                             TempVBPath += "SSETUP";
  330.                             TempVBPath  =  FormatFileNameValid( TempVBPath, TRUE );
  331.                             TempVBPath.MakeUpper();
  332.                             UserPath = TempVBPath ;
  333.                             iType = TYPE_VB;
  334.                             }
  335.                         }
  336.                     if ( DoesFileExist( "TCW.INI", FALSE) )
  337.                         {
  338.                         TempVBPath = GetWinFileAssociation( "PRJ" ) ;
  339.                         if ( TempVBPath.GetLength() > 0 )
  340.                             {
  341.                             TempVBPath =  TempVBPath.Left( TempVBPath.GetLength() - 10 ); // kill BIN\\TCW.EXE
  342.                             TempVBPath += "SSETUP" ;
  343.                             TempVBPath = FormatFileNameValid( TempVBPath, TRUE ) ;
  344.                             TempVBPath.MakeUpper();
  345.                             UserPath = TempVBPath ;
  346.                             iType = TYPE_TCW;
  347.                             }
  348.                         }
  349.                     if ( DoesFileExist( "AUTOEXEC.BAT", FALSE) )
  350.                         {
  351.                         GetPrivateProfileString( "Microsoft Visual C++", "Path1", "", TempVBPath.GetBuffer(100), 98, "MSVC.INI");
  352.                         TempVBPath.ReleaseBuffer();
  353.                         if ( TempVBPath.GetLength() > 0 )
  354.                             {
  355.                             TempVBPath =  TempVBPath.Left( TempVBPath.GetLength() - 3 ); // kill BIN
  356.                             TempVBPath += "SSETUP";
  357.                             TempVBPath  =  FormatFileNameValid( TempVBPath, TRUE );
  358.                             TempVBPath.MakeUpper();
  359.                             UserPath = TempVBPath ;
  360.                             iType = TYPE_MFC;
  361.                             }
  362.                         }                                        
  363.                     if ( UserPath.GetLength() < 1 )
  364.                         {
  365.                         GetWindowsDirectory( UserPath.GetBuffer(180), 178 );
  366.                         UserPath.ReleaseBuffer();
  367.                         UserPath = UserPath.Left( 3 );
  368.                         UserPath += "SSETUP\\" ;
  369.                         iType = TYPE_NONE;
  370.                         }
  371.                     SetDlgItemText( IDC_EDITSRCPATH, UserPath );
  372.                     
  373.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  374.                 for ( i = 0 ; i <  NumberOfSections ; i++ )
  375.                     {
  376.                     if ( Section[i].Name.GetLength()> 0 )
  377.                         Section[i].lSize = GetSectionSize( Section[i].Name );
  378.                     }  
  379.                 /////////////////////////////////////////////////////////// Specific //////////////////////////////////////////////////////////////////////
  380.                 Section[0].bSelected = TRUE;
  381.                 Section[1].bSelected = (iType == TYPE_VB)?TRUE:FALSE;
  382.                 Section[2].bSelected = TRUE;
  383.                 Section[3].bSelected = TRUE;
  384.                 Section[4].bSelected = TRUE;
  385.                 Section[5].bSelected = TRUE;
  386.                 }    
  387.             (CEdit*)(GetDlgItem( IDC_EDITSRCPATH))->SetFocus(); 
  388.             ((CEdit*)(GetDlgItem( IDC_EDITSRCPATH)))->SetSel( 0, -1L );
  389.             return FALSE;  // return TRUE  unless you set the focus to a control
  390.             }
  391.             
  392.  
  393.             // ----------------------------------------------------------
  394.             //  CMain::PM_FIRST
  395.             //    Main function
  396.             // ----------------------------------------------------------
  397.             afx_msg LRESULT CMain::OnFirstPrivate( WPARAM wParam, LPARAM lParam )
  398.             {
  399.             CChoice1 box1( this );            // path selection
  400.             CChoice2 box2( this );            // options selection
  401.             int test2, iResult;
  402.             register int i = 0;
  403.             CString szLogFile;
  404.             CString SrcHelpFile, DestHelpFile, Message,TempPath;
  405.             /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  406.             FIRSTBOX:                   
  407.             if ( box1.DoModal() == IDCANCEL )
  408.                 {
  409.                 if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"Etes vous certain de vouloir\nabandonner l' installation?":
  410.                             "Are you sure you wish to abort\nthe installation program?", Dialog1Title, MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION ) == IDYES )
  411.                     goto END;
  412.                 else
  413.                     goto FIRSTBOX;
  414.                 }
  415.             
  416.             SECONDBOX:
  417.             // ----- Put Panel 2 if necessary -----
  418.             if ( iPanel2Bitmap == 0 )
  419.                 {
  420.                 if ( szPanel2Title.GetLength() > 0 )
  421.                     {
  422.                     SetTextLogo( szPanel2Title, szPanel2TitleFont, iPanel2TitleSize, lPanel2TitleColor, bPanel2Title3D, bPanel2TitleBold );  
  423.                     if ( szPanel2Detail.GetLength() > 0 )
  424.                         SetTextDetail( szPanel2Detail, szPanel2DetailFont, iPanel2DetailSize, lPanel2DetailColor, bPanel2Detail3D, bPanel2DetailBold );  
  425.                     SetLogoType( TRUE );
  426.                     SendMessage( WM_PAINT );
  427.                     }
  428.                 }
  429.             else 
  430.                 {
  431.                 SetLogo( AfxGetInstanceHandle(), iPanel2Bitmap );
  432.                 SetLogoType( FALSE );
  433.                 SendMessage( WM_PAINT );
  434.                 }
  435.             
  436.             test2 = box2.DoModal();
  437.             if ( test2 == IDCANCEL )
  438.                 {
  439.                 if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"Etes vous certain de vouloir\nabandonner l' installation?":
  440.                             "Are you sure you wish to abort\nthe installation program?", Dialog1Title, MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION ) == IDYES )
  441.                     goto END;
  442.                 goto SECONDBOX;
  443.                 }
  444.             else if ( test2 == IDCHANGEPATH )
  445.                 goto FIRSTBOX;
  446.             // ----- Put Panel 3 if necessary -----
  447.             if ( iPanel3Bitmap == 0 )
  448.                 {
  449.                 if ( szPanel3Title.GetLength() > 0 )
  450.                     {
  451.                     SetTextLogo( szPanel3Title, szPanel3TitleFont, iPanel3TitleSize, lPanel3TitleColor, bPanel3Title3D, bPanel3TitleBold );  
  452.                     if ( szPanel3Detail.GetLength() > 0 )
  453.                         SetTextDetail( szPanel3Detail, szPanel3DetailFont, iPanel3DetailSize, lPanel3DetailColor, bPanel3Detail3D, bPanel3DetailBold );  
  454.                     SetLogoType( TRUE );
  455.                     SendMessage( WM_PAINT );
  456.                     }
  457.                 }
  458.             else 
  459.                 {
  460.                 SetLogo( AfxGetInstanceHandle(), iPanel3Bitmap );
  461.                 SetLogoType( FALSE );
  462.                 SendMessage( WM_PAINT );
  463.                 }
  464.             // log file ------
  465.             if ( bUseLogFile )
  466.                 {
  467.                 szLogFile = UserPath + szLogFileName;
  468.                 SetLogFile( szLogFile );
  469.                 }
  470.             // Select sections
  471.             for ( i = 0 ; i <  NumberOfSections ; i++ )
  472.                 {
  473.                 if ( Section[i].bSelected )
  474.                     {
  475.                     if ( Section[i].Directory.GetLength() > 0 )
  476.                         TempPath = UserPath + Section[i].Directory;
  477.                     else
  478.                         TempPath = UserPath;
  479.                     AddSectionToCopyList( Section[i].Name, TempPath );
  480.                     }
  481.                 }
  482.             iResult = GoSetup( m_hWnd, TRUE );        // TRUE specifie we will use FINISH.EXE to clean up the temp dir when setup is complete
  483.             
  484.             /////////////////////////////////////////////////////////// Specific //////////////////////////////////////////////////////////////////////
  485.             if ( iResult == SETUP_SUCCESSFUL )
  486.                 {   
  487.                 SrcHelpFile = UserPath;
  488.                 SrcHelpFile += ( iLanguage == LANGUAGE_FRENCH )? "FRSTUDIO.HLP" : "USSTUDIO.HLP";
  489.                 DestHelpFile = UserPath + "SSTUDIO.HLP";
  490.                 if ( DoesFileExist( SrcHelpFile, TRUE ) )
  491.                     {
  492.                     if ( DoesFileExist( DestHelpFile, TRUE ) )
  493.                         DeleteFile( DestHelpFile );
  494.                     RenameFile( SrcHelpFile, DestHelpFile );
  495.                     }
  496.                 SrcHelpFile = UserPath;
  497.                 SrcHelpFile += ( iLanguage == LANGUAGE_FRENCH )? "USSTUDIO.HLP" : "FRSTUDIO.HLP";
  498.                 if ( DoesFileExist( SrcHelpFile, TRUE ) )
  499.                     DeleteFile( SrcHelpFile );
  500.                     
  501.             /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  502.             if ( Section[0].bSelected )        
  503.                 {
  504.                 if ( bInstallIcons )
  505.                     {
  506.                     Message = ( iLanguage == LANGUAGE_FRENCH )?"Souhaitez vous installer les icones de ":"Do you wish to install ";
  507.                     Message += szProductName;
  508.                     Message += ( iLanguage == LANGUAGE_FRENCH )?"?":" icons?";
  509.                     if ( MessageBox( Message, Dialog1Title, MB_YESNO | MB_ICONQUESTION) == IDYES )            
  510.                         {
  511.                         CString IconPath;
  512.                         for ( i = 0 ; i < NumberOfIcons ; i++ )
  513.                             {
  514.                             IconPath = UserPath + IconEntry[i].szIconRelativeName;
  515.                             if ( DoesFileExist( IconPath, TRUE ) )
  516.                                 {
  517.                                 if ( IconEntry[i].EIconText.GetLength() > 0 )
  518.                                     {
  519.                                     AddItemToProgman( ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName, IconPath,
  520.                                                                       ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FIconName : IconEntry[i].EIconName,
  521.                                                                       ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FIconText : IconEntry[i].EIconText );
  522.                                     ShowProgmanGroup( ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName );
  523.                                     }
  524.                                 else
  525.                                     {               
  526.                                     AddProgmanGroup(( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName);
  527.                                     ShowProgmanGroup( ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName );
  528.                                     AddProgmanItem( IconPath, ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FIconName : IconEntry[i].EIconName );
  529.                                     }
  530.                               }
  531.                              }
  532.                         ShowWindow(SW_SHOWNORMAL );
  533.                        }
  534.                     }
  535.                 }
  536.             
  537.             /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  538.             if ( bMakeAssociation )
  539.                 {
  540.                 for ( i = 0; i < NumberOfAsso; i++ )
  541.                     {
  542.                     DestHelpFile = UserPath + WFAsso[i].szProgName;
  543.                     if ( DoesFileExist( DestHelpFile, TRUE ))
  544.                         CreateWinFileAssociation( WFAsso[i].szExt, DestHelpFile );
  545.                     }
  546.                 }
  547.             if ( szLaunch != "" )
  548.                 {
  549.                 DestHelpFile = szLaunch;
  550.                 DestHelpFile = DestHelpFile.Right( 3 );
  551.                 if ( DestHelpFile == "HLP" )
  552.                     {
  553.                     DestHelpFile = UserPath + szLaunch;
  554.                     if ( DoesFileExist( DestHelpFile, TRUE ))
  555.                         {
  556.                         if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"L' installation est terminΘe.\nVoulez vous parcourir le fichier\nd'aide maintenant?":
  557.                             "The installation is complete.\nDo you want to have a look at\nthe help file now?", Dialog1Title ,MB_YESNO | MB_ICONQUESTION ) == IDYES )
  558.                             ::WinHelp( NULL, DestHelpFile, HELP_CONTENTS, 0L );
  559.                         }
  560.                     }
  561.                 else
  562.                     {
  563.                     DestHelpFile = UserPath + szLaunch;
  564.                     if ( DoesFileExist( DestHelpFile, TRUE ))
  565.                         {
  566.                         if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"L' installation est terminΘe.\nVoulez vous lancer le programme maintenant?":
  567.                             "The installation is complete.\nDo you want to have a look at the program now?", Dialog1Title ,MB_YESNO | MB_ICONQUESTION ) == IDYES )
  568.                             WinExec( DestHelpFile, SW_SHOW );
  569.                         }                                                       
  570.                     }
  571.                 }
  572.             }// Sucessful installation
  573.         else
  574.             {
  575.             MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"L' installation est incomplΦte.\nPour utiliser ce produit, vous devrez l' installer α nouveau.":
  576.             "Installation is not complete.\nPlease to use this program, install it again.", Dialog1Title, MB_OK | MB_ICONEXCLAMATION );
  577.             }
  578.         
  579.         END:    
  580.             PostMessage( WM_CLOSE );                          
  581.             return TRUE;
  582.             }
  583.             
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  591. //                                                                        Implementation - Generic                                                                                                                        //
  592. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  593.  
  594. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  595. // CSetupApp
  596. // Application implementation
  597. //
  598.             
  599.             // ----------------------------------------------------------
  600.             //  Message MAP
  601.             // ----------------------------------------------------------
  602.             BEGIN_MESSAGE_MAP(CSetupApp, CWinApp)
  603.                 //{{AFX_MSG_MAP(CSetupApp)
  604.                     // NOTE - the ClassWizard will add and remove mapping macros here.
  605.                     //    DO NOT EDIT what you see in these blocks of generated code !
  606.                 //}}AFX_MSG_MAP
  607.                 // Standard file based document commands
  608.             END_MESSAGE_MAP()
  609.             
  610.         
  611.         
  612.             
  613.             // ----------------------------------------------------------
  614.             //  Application instanciation
  615.             // ----------------------------------------------------------
  616.             CSetupApp NEAR theApp;
  617.             
  618.             // ----------------------------------------------------------
  619.             //  Instance Initialization
  620.             // ----------------------------------------------------------
  621.             BOOL CSetupApp::InitInstance()
  622.                 {
  623.                 SetDialogBkColor();                // set dialog background color to gray
  624.                 EnableVBX();                          // Initialize VBX support
  625.                 Ctl3dRegister( AfxGetInstanceHandle() );        // See CTL3D API
  626.                 UserConfigSize = 0L;
  627.                 // We need to retrieve the COMMAND line arguments
  628.                 if (m_lpCmdLine[0] != '\0')
  629.                     {
  630.                     ExtractParameter( m_lpCmdLine, (LPSTR)szOriginalPath, 1 );
  631.                     ExtractParameter( m_lpCmdLine, (LPSTR)szTempSetupPath, 2 );
  632.                     }
  633.                 else
  634.                     {
  635.                     ::MessageBox( NULL, "This program cannot be launched directly.\nSETUP.EXE must be used to to this.\n", Dialog1Title, MB_OK | MB_ICONSTOP );
  636.                     return FALSE;
  637.                     }
  638.                 CFirst boite1;
  639.                 boite1.DoModal();
  640.                 if ( bIsSetupOK )
  641.                     {
  642.                     CMain MainBox;
  643.                     MainBox.DoModal();
  644.                     }
  645.                 return TRUE;
  646.                 }
  647.             
  648.             // ----------------------------------------------------------
  649.             //  Intance Exit ( like WEP )
  650.             // ----------------------------------------------------------
  651.             int CSetupApp::ExitInstance()
  652.                 {
  653.                 Ctl3dUnregister( AfxGetInstanceHandle() );
  654.                 DeleteSystemDir(  );
  655.                 return CWinApp::ExitInstance();
  656.                 }
  657.             
  658.             // ----------------------------------------------------------
  659.             //  VBX Event MAP
  660.             // ----------------------------------------------------------
  661.             //{{AFX_VBX_REGISTER_MAP()
  662.             //}}AFX_VBX_REGISTER_MAP
  663.             
  664.             
  665.             
  666.             
  667.             
  668.             
  669. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  670. // CFirst dialog - Splash style and initialization managment
  671. //
  672.             
  673.             
  674.             
  675.             
  676.             // ----------------------------------------------------------
  677.             //  Constructor
  678.             // ----------------------------------------------------------
  679.             CFirst::CFirst(CWnd* pParent /*=NULL*/)
  680.                 : CDialog(CFirst::IDD, pParent)
  681.                 {
  682.                 //{{AFX_DATA_INIT(CFirst)
  683.                     // NOTE: the ClassWizard will add member initialization here
  684.                 //}}AFX_DATA_INIT
  685.                 }
  686.             
  687.             
  688.             
  689.             // ----------------------------------------------------------
  690.             //  Data Exchange
  691.             // ----------------------------------------------------------
  692.             void CFirst::DoDataExchange(CDataExchange* pDX)
  693.                 {
  694.                 CDialog::DoDataExchange(pDX);
  695.                 //{{AFX_DATA_MAP(CFirst)
  696.                     // NOTE: the ClassWizard will add DDX and DDV calls here
  697.                 //}}AFX_DATA_MAP
  698.                 }
  699.             
  700.             // ----------------------------------------------------------
  701.             //  Message MAP
  702.             // ----------------------------------------------------------
  703.             BEGIN_MESSAGE_MAP(CFirst, CDialog)
  704.                 //{{AFX_MSG_MAP(CFirst)
  705.                 ON_MESSAGE( PM_FIRST, OnFirstPrivate )
  706.                 ON_WM_CLOSE()
  707.                 ON_WM_DESTROY()
  708.                 //}}AFX_MSG_MAP
  709.             END_MESSAGE_MAP()
  710.             
  711.             
  712.             
  713.             // ----------------------------------------------------------
  714.             //  WM_INITDIALOG
  715.             //  Interface managment and Call OnFirstPrivate
  716.             // ----------------------------------------------------------
  717.             BOOL CFirst::OnInitDialog()
  718.                 {
  719.                 CDialog::OnInitDialog();
  720.                 if ((hfontDlg = (HFONT) SendMessage(WM_GETFONT) )) 
  721.                     {
  722.                     if (::GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont)) 
  723.                         {
  724.                         lFont.lfWeight = FW_NORMAL;
  725.                         if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont)) 
  726.                             SendDlgItemMessage( IDC_STATIC1, WM_SETFONT, (WPARAM) hfontDlg, 0);
  727.                         }
  728.                     }
  729.                 SetWindowText( Dialog1Title );
  730.                 SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) );
  731.                 Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL );
  732.                 CenterDialogBox( m_hWnd );
  733.                 BringWindowToTop();
  734.                 FirstCanClose = FALSE;
  735.                 PostMessage( PM_FIRST );
  736.                 return TRUE;  // return TRUE  unless you set the focus to a control
  737.                 }
  738.             
  739.             
  740.             // ----------------------------------------------------------
  741.             //  PM_FIRST private message function
  742.             //  Guess the user Language 
  743.             //  Set interface
  744.             //  Call SetupInitialize
  745.             // ----------------------------------------------------------
  746.             afx_msg LRESULT CFirst::OnFirstPrivate( WPARAM wParam, LPARAM lParam )
  747.                 {
  748.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  749.                 static char far szTemp[6];                                                                                                
  750.                 // Have a look in WIN.INI for Language detection
  751.                 SendMessage( WM_PAINT );
  752.                 GiveTheHand();
  753.                 ::GetProfileString( "intl", "sLanguage", "", (LPSTR)szTemp, 4 );
  754.                 AnsiUpper( szTemp );
  755.                 if (lstrcmp( szTemp, "FRA" )== 0 )
  756.                     iLanguage = LANGUAGE_FRENCH;
  757.                 else
  758.                     iLanguage = LANGUAGE_ENGLISH;
  759.                     
  760.                 bIsSetupOK = SetupInitialize( szYourName, szYourPassword, iLanguage, (LPSTR)szOriginalPath, (LPSTR)szTempSetupPath );
  761.                 SetupSetTitle( szSetupBoxTitle );
  762.                 GiveTheHand();
  763.                 if ( bUseSharedBatch )
  764.                     {                                   
  765.                     CString szUserBatchFile, szUserBatchDir;
  766.                     GetWindowsDirectory( szUserBatchFile.GetBuffer(182), 180 );
  767.                     szUserBatchFile.ReleaseBuffer();
  768.                     szUserBatchFile = szUserBatchFile.Left( 3 );
  769.                     szUserBatchDir = szUserBatchFile;
  770.                     szUserBatchFile += ( szBatchFile != "") ? szBatchFile : "SYSSETUP.TMP\\SYSSETUP.BAT" ;
  771.                     szUserBatchDir += ( szBatchDir != "")? szBatchDir : "SYSSETUP.TMP\\";
  772.                     SetSharedBatchFile( szUserBatchFile, szUserBatchDir );
  773.                     }
  774.                 SetPatternBrushStandard( iBackgroundPaper );
  775.                 SetupSetBeepMode ( bBeepMode );            // Select or not the BEEP mode
  776.                 SetVerifyMode( bVerifyMode );            // Select or deselect the File Size Verification mode ( if size is bad, setup will abort ).
  777.                 // ---- panel 1 ----
  778.                 if ( iPanel1Bitmap == 0 )
  779.                     {
  780.                     if ( szPanel1Title.GetLength() > 0 )
  781.                         {
  782.                         SetTextLogo( szPanel1Title, szPanel1TitleFont, iPanel1TitleSize, lPanel1TitleColor, bPanel1Title3D, bPanel1TitleBold );  
  783.                         if ( szPanel1Detail.GetLength() > 0 )
  784.                             SetTextDetail( szPanel1Detail, szPanel1DetailFont, iPanel1DetailSize, lPanel1DetailColor, bPanel1Detail3D, bPanel1DetailBold );  
  785.                         SetLogoType( TRUE );
  786.                         }
  787.                     }
  788.                 else 
  789.                     {
  790.                     SetLogo( AfxGetInstanceHandle(), iPanel1Bitmap );
  791.                     SetLogoType( FALSE );
  792.                     }
  793.                 
  794.                 FirstCanClose = TRUE;
  795.                 PostMessage( WM_CLOSE );
  796.                 return TRUE;
  797.                 }    
  798.             
  799.             
  800.             // ----------------------------------------------------------
  801.             //  WM_CLOSE
  802.             //    Do not close during Initialization
  803.             // ----------------------------------------------------------
  804.             void CFirst::OnClose()
  805.                 {
  806.                 if ( FirstCanClose )                     // Disable user window closing during Initialisation....
  807.                     CDialog::OnClose();
  808.                 else
  809.                     MessageBeep( -1 );            
  810.                 }
  811.                 
  812.                 
  813.                 
  814.             
  815.             
  816. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  817. // CMain dialog - In fact a pseudo dialog box only use with the ShowMainWindow CSETUP.DLL function
  818. //
  819.             
  820.             // ----------------------------------------------------------
  821.             //  Constructor
  822.             // ----------------------------------------------------------
  823.             CMain::CMain(CWnd* pParent /*=NULL*/)
  824.                 : CDialog(CMain::IDD, pParent)
  825.                 {
  826.                 //{{AFX_DATA_INIT(CMain)
  827.                     // NOTE: the ClassWizard will add member initialization here
  828.                 //}}AFX_DATA_INIT
  829.                 }
  830.             
  831.             // ----------------------------------------------------------
  832.             //  Data Exchange
  833.             // ----------------------------------------------------------
  834.             void CMain::DoDataExchange(CDataExchange* pDX)
  835.                 {
  836.                 CDialog::DoDataExchange(pDX);
  837.                 //{{AFX_DATA_MAP(CMain)
  838.                     // NOTE: the ClassWizard will add DDX and DDV calls here
  839.                 //}}AFX_DATA_MAP
  840.                 }
  841.             
  842.             // ----------------------------------------------------------
  843.             //  Message MAP
  844.             // ----------------------------------------------------------
  845.             BEGIN_MESSAGE_MAP(CMain, CDialog)
  846.                 //{{AFX_MSG_MAP(CMain)
  847.                 ON_MESSAGE( PM_FIRST, OnFirstPrivate )
  848.                 ON_MESSAGE( SN_NEWDISKREQUIRED, OnNewDisk )
  849.                 ON_WM_PAINT()
  850.                 ON_WM_NCPAINT()
  851.                 //}}AFX_MSG_MAP
  852.             END_MESSAGE_MAP()
  853.             
  854.             
  855.             
  856.             
  857.             
  858.             // ----------------------------------------------------------
  859.             //  WM_INITDIALOG
  860.             //    Call CMain::OnFirstPrivate
  861.             // ----------------------------------------------------------
  862.             BOOL CMain::OnInitDialog()
  863.                 {
  864.                 CDialog::OnInitDialog();
  865.                 SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) );
  866.                 SetWindowText( Dialog1Title );
  867.                 BringWindowToTop();
  868.                 PostMessage( PM_FIRST );
  869.                 return TRUE;  // return TRUE  unless you set the focus to a control
  870.                 }
  871.             
  872.             
  873.             
  874.             
  875.             
  876.             // ----------------------------------------------------------
  877.             //  SN_NEWDISKREQUIRED
  878.             //    You will receive this message
  879.             //    when CSetup shows the New Disk
  880.             //    Required dialog box.
  881.             // ----------------------------------------------------------
  882.             afx_msg LRESULT CMain::OnNewDisk( WPARAM wParam, LPARAM lParam )
  883.                 {
  884.                 return TRUE;
  885.                 };
  886.             
  887.             
  888.             // ----------------------------------------------------------
  889.             //  WM_PAINT
  890.             //    Call ShowMainWindow CSETUP.DLL function
  891.             // ----------------------------------------------------------
  892.             void CMain::OnPaint()
  893.                 {                                 
  894.                 CPaintDC dc(this);                                                                                                                
  895.                 RedrawWindow( NULL, NULL, RDW_NOFRAME | RDW_NOERASE );  // To prevent flashing
  896.                 ShowMainWindow( m_hWnd );      // The main function wich paint your window as a Setup Like window ( for PAINT )
  897.                 RedrawWindow( NULL, NULL, RDW_NOFRAME | RDW_NOERASE );  // To prevent flashing
  898.                 }
  899.             
  900.             
  901.             
  902.             // ----------------------------------------------------------
  903.             //  WM_PAINT
  904.             //    Call ShowMainWindow CSETUP.DLL function
  905.             // ----------------------------------------------------------
  906.             void CMain::OnNcPaint()
  907.                 {
  908.                 RedrawWindow( NULL, NULL, RDW_NOERASE | RDW_VALIDATE );  // To prevent flashing 
  909.                 ShowMainWindow( m_hWnd );      // The main function wich paint your window as a Setup Like window ( for PAINT )
  910.                 RedrawWindow( NULL, NULL, RDW_NOERASE | RDW_VALIDATE );  // To prevent flashing 
  911.                 }
  912.  
  913.  
  914.  
  915.  
  916.     
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  925. // CChoice1 dialog allows the user to choose Language and main Destination PATH
  926. //
  927.             
  928.             // ----------------------------------------------------------
  929.             //  Constructor
  930.             // ----------------------------------------------------------
  931.             CChoice1::CChoice1(CWnd* pParent /*=NULL*/)
  932.                 : CDialog(CChoice1::IDD, pParent)
  933.             {
  934.                 //{{AFX_DATA_INIT(CChoice1)
  935.                     // NOTE: the ClassWizard will add member initialization here
  936.                 //}}AFX_DATA_INIT
  937.             }
  938.             
  939.             
  940.             // ----------------------------------------------------------
  941.             //  Data Exchange ( not used )
  942.             // ----------------------------------------------------------
  943.             void CChoice1::DoDataExchange(CDataExchange* pDX)
  944.             {
  945.                 CDialog::DoDataExchange(pDX);
  946.                 //{{AFX_DATA_MAP(CChoice1)
  947.                     // NOTE: the ClassWizard will add DDX and DDV calls here
  948.                 //}}AFX_DATA_MAP
  949.             }
  950.             
  951.             // ----------------------------------------------------------
  952.             //  Message MAP
  953.             // ----------------------------------------------------------
  954.             BEGIN_MESSAGE_MAP(CChoice1, CDialog)
  955.                 //{{AFX_MSG_MAP(CChoice1)
  956.                 ON_BN_CLICKED(IDC_RADIOENGLISH, OnClickedRadioenglish)
  957.                 ON_BN_CLICKED(IDC_RADIOFRENCH, OnClickedRadiofrench)
  958.                 ON_EN_CHANGE(IDC_EDITSRCPATH, OnChangeEditsrcpath)
  959.                 ON_WM_DESTROY()
  960.                 //}}AFX_MSG_MAP
  961.             END_MESSAGE_MAP()
  962.             
  963.             
  964.             
  965.             
  966.             
  967.             // ----------------------------------------------------------
  968.             //  WM_COMMAND:ONLANGUAGE
  969.             //  Change the language
  970.             // ----------------------------------------------------------
  971.             void CChoice1::OnClickedRadioenglish()
  972.                 {
  973.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  974.                 SetupSetLanguage( LANGUAGE_ENGLISH );
  975.                 iLanguage = LANGUAGE_ENGLISH;
  976.                 SetDlgItemText( IDC_GROUPLANGUAGE, "Your language ");
  977.                 CString ProductName;
  978.                 ProductName = ( iLanguage == LANGUAGE_FRENCH )? "Indiquer le rΘpertoire ou vous souhaitez installer ": "Please, give the directory in which you want to install ";
  979.                 ProductName += szProductName;
  980.                 ProductName += ( iLanguage == LANGUAGE_FRENCH )?" et cliquer sur OK:":" and click on OK";
  981.                 SetDlgItemText( IDC_TEXTE, ProductName );
  982.                 SetDlgItemText( IDCANCEL, "&Abort");
  983.                 }
  984.             
  985.             // ----------------------------------------------------------
  986.             //  WM_COMMAND:ONLANGUAGE
  987.             //  Change the language
  988.             // ----------------------------------------------------------
  989.             void CChoice1::OnClickedRadiofrench()
  990.                 {
  991.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  992.                 SetupSetLanguage( LANGUAGE_FRENCH );
  993.                 iLanguage = LANGUAGE_FRENCH;
  994.                 SetDlgItemText( IDC_GROUPLANGUAGE, "Votre langage ");
  995.                 CString ProductName;
  996.                 ProductName = ( iLanguage == LANGUAGE_FRENCH )? "Indiquer le rΘpertoire ou vous souhaitez installer ": "Please, give the directory in which you want to install ";
  997.                 ProductName += szProductName;
  998.                 ProductName += ( iLanguage == LANGUAGE_FRENCH )?" et cliquer sur OK:":" and click on OK";
  999.                 SetDlgItemText( IDC_TEXTE, ProductName );
  1000.                 SetDlgItemText( IDCANCEL, "&Abandonner");
  1001.                 }
  1002.             
  1003.             // ----------------------------------------------------------
  1004.             //  WM_COMMAND:ONPATH
  1005.             //  Change the path
  1006.             // ----------------------------------------------------------
  1007.             void CChoice1::OnChangeEditsrcpath()
  1008.                 {
  1009.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1010.                 CString TempDestName;
  1011.                 GetDlgItemText( IDC_EDITSRCPATH, TempDestName.GetBuffer( 162 ), 160 );
  1012.                 TempDestName.ReleaseBuffer();
  1013.                 if ( TempDestName.GetLength() < 1 )
  1014.                     GetDlgItem( IDOK)->EnableWindow( FALSE );
  1015.                 else
  1016.                     GetDlgItem( IDOK)->EnableWindow( TRUE );
  1017.                 }
  1018.             
  1019.             // ----------------------------------------------------------
  1020.             //  WM_COMMAND:ONOK
  1021.             //  Check the path thanks to
  1022.             //    CSETUP functions
  1023.             // ----------------------------------------------------------
  1024.             void CChoice1::OnOK()
  1025.                 {
  1026.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1027.                 CString TempDestName;
  1028.                 GetDlgItemText( IDC_EDITSRCPATH, TempDestName.GetBuffer(162), 160 );
  1029.                 TempDestName.ReleaseBuffer();
  1030.                 if ( !IsFileName( TempDestName, FILENAME_DIRWITHSLASH, CHECK_ROOTDIRSEXIST) )
  1031.                     {
  1032.                     TempDestName = FormatFileNameValid( TempDestName, TRUE);
  1033.                     SetDlgItemText( IDC_EDITSRCPATH, TempDestName );
  1034.                     }
  1035.                 if ( IsFileName( TempDestName,  FILENAME_DIRWITHSLASH, CHECK_ROOTDIRSEXIST) )
  1036.                     {
  1037.                     UserPath = TempDestName;
  1038.                     CDialog::OnOK();
  1039.                     }
  1040.                 else
  1041.                     {
  1042.                     MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"Le rΘpertoire mentionnΘ n' est pas valide.\nSi vous avez mentionnΘ des sous rΘpertoires\nceux ci doivent exister.\n":
  1043.                     "Directory name is not valid.\nIf you want to specifie sub directories\nthey must exist.\n", Dialog1Title, MB_OK | MB_ICONEXCLAMATION );
  1044.                     (CEdit*)(GetDlgItem( IDC_EDITSRCPATH))->SetFocus(); 
  1045.                     ((CEdit*)(GetDlgItem( IDC_EDITSRCPATH)))->SetSel( 0, -1 );
  1046.                     }
  1047.                 }
  1048.             
  1049.             
  1050.             
  1051.             
  1052.             
  1053.             
  1054.             
  1055. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1056. // CChoice2 dialog allows the user to select files to install
  1057. //
  1058.             
  1059.             // ----------------------------------------------------------
  1060.             //  Constructor
  1061.             // ----------------------------------------------------------
  1062.             CChoice2::CChoice2(CWnd* pParent /*=NULL*/)
  1063.                 : CDialog(CChoice2::IDD, pParent)
  1064.             {
  1065.                 //{{AFX_DATA_INIT(CChoice2)
  1066.                     // NOTE: the ClassWizard will add member initialization here
  1067.                 //}}AFX_DATA_INIT
  1068.             }
  1069.             
  1070.             // ----------------------------------------------------------
  1071.             //  Data Exchange ( Not use )
  1072.             // ----------------------------------------------------------
  1073.             void CChoice2::DoDataExchange(CDataExchange* pDX)
  1074.             {
  1075.                 CDialog::DoDataExchange(pDX);
  1076.                 //{{AFX_DATA_MAP(CChoice2)
  1077.                     // NOTE: the ClassWizard will add DDX and DDV calls here
  1078.                 //}}AFX_DATA_MAP
  1079.             }
  1080.             
  1081.             // ----------------------------------------------------------
  1082.             //  Message MAP
  1083.             // ----------------------------------------------------------
  1084.             BEGIN_MESSAGE_MAP(CChoice2, CDialog)
  1085.                 //{{AFX_MSG_MAP(CChoice2)
  1086.                 ON_BN_CLICKED(IDB_CHANGEPATH, OnClickedChangepath)
  1087.                 ON_BN_CLICKED(IDC_CHECK1, OnClickedCheck1)
  1088.                 ON_BN_CLICKED(IDC_CHECK2, OnClickedCheck2)
  1089.                 ON_BN_CLICKED(IDC_CHECK3, OnClickedCheck3)
  1090.                 ON_BN_CLICKED(IDC_CHECK4, OnClickedCheck4)
  1091.                 ON_BN_CLICKED(IDC_CHECK5, OnClickedCheck5)
  1092.                 ON_BN_CLICKED(IDC_CHECK6, OnClickedCheck6)
  1093.                 ON_BN_CLICKED(IDC_CHECK7, OnClickedCheck7)
  1094.                 ON_BN_CLICKED(IDC_CHECK8, OnClickedCheck8)
  1095.                 ON_BN_CLICKED(IDC_CHECK9, OnClickedCheck9)
  1096.                 ON_BN_CLICKED(IDC_CHECK10, OnClickedCheck10)
  1097.                 ON_BN_CLICKED(IDC_CHECK11, OnClickedCheck11)
  1098.                 ON_BN_CLICKED(IDC_CHECK12, OnClickedCheck12)
  1099.                 ON_BN_CLICKED(IDC_CHECK13, OnClickedCheck13)
  1100.                 ON_BN_CLICKED(IDC_CHECK14, OnClickedCheck14)
  1101.                 ON_BN_CLICKED(IDC_CHECK15, OnClickedCheck15)
  1102.     ON_WM_DESTROY()
  1103.     //}}AFX_MSG_MAP
  1104.             END_MESSAGE_MAP()
  1105.             
  1106.             
  1107.             
  1108.             
  1109.             // ----------------------------------------------------------
  1110.             //  WM_INITDIALOG
  1111.             //  Check boxes managment
  1112.             // ----------------------------------------------------------
  1113.             BOOL CChoice2::OnInitDialog()
  1114.                 {
  1115.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1116.                 register int i=0;
  1117.                 CDialog::OnInitDialog();
  1118.                 SetWindowText( Dialog3Title );
  1119.                 if ((hfontDlg = (HFONT) SendMessage(WM_GETFONT) )) 
  1120.                     {
  1121.                     if (::GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont)) 
  1122.                         {
  1123.                         lFont.lfWeight = FW_NORMAL;
  1124.                         if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont)) 
  1125.                             {
  1126.                             SendDlgItemMessage( IDC_CHECK1, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1127.                             SendDlgItemMessage( IDC_CHECK2, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1128.                             SendDlgItemMessage( IDC_CHECK3, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1129.                             SendDlgItemMessage( IDC_CHECK4, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1130.                             SendDlgItemMessage( IDC_CHECK5, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1131.                             SendDlgItemMessage( IDC_CHECK6, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1132.                             SendDlgItemMessage( IDC_CHECK7, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1133.                             SendDlgItemMessage( IDC_CHECK8, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1134.                             SendDlgItemMessage( IDC_CHECK9, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1135.                             SendDlgItemMessage( IDC_CHECK10, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1136.                             SendDlgItemMessage( IDC_CHECK11, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1137.                             SendDlgItemMessage( IDC_CHECK12, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1138.                             SendDlgItemMessage( IDC_CHECK13, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1139.                             SendDlgItemMessage( IDC_CHECK14, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1140.                             SendDlgItemMessage( IDC_CHECK15, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1141.                             SendDlgItemMessage( IDC_K1, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1142.                             SendDlgItemMessage( IDC_K2, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1143.                             SendDlgItemMessage( IDC_K3, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1144.                             SendDlgItemMessage( IDC_K4, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1145.                             SendDlgItemMessage( IDC_K5, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1146.                             SendDlgItemMessage( IDC_K6, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1147.                             SendDlgItemMessage( IDC_K7, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1148.                             SendDlgItemMessage( IDC_K8, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1149.                             SendDlgItemMessage( IDC_K9, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1150.                             SendDlgItemMessage( IDC_K10, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1151.                             SendDlgItemMessage( IDC_K11, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1152.                             SendDlgItemMessage( IDC_K12, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1153.                             SendDlgItemMessage( IDC_K13, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1154.                             SendDlgItemMessage( IDC_K14, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1155.                             SendDlgItemMessage( IDC_K15, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1156.                             SendDlgItemMessage( IDC_GROUP, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1157.                             SendDlgItemMessage( IDC_TEXTECSIZE, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1158.                             SendDlgItemMessage( IDC_KCONFIG, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1159.                             SendDlgItemMessage( IDC_TEXTETOTALSIZE, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1160.                             SendDlgItemMessage( IDC_KTOTAL, WM_SETFONT, (WPARAM) hfontDlg, 0);
  1161.                             }
  1162.                         }
  1163.                     }
  1164.                 // We resize the dialog box depending of number of items
  1165.                 RECT r, r2, r3;
  1166.                 GetWindowRect( &r3 );
  1167.                 GetDlgItem( IDC_CHECK1 )->GetWindowRect( &r2 );
  1168.                 GetDlgItem( IDC_GROUP )->GetWindowRect( &r );
  1169.                 GetDlgItem( IDC_GROUP )->SetWindowPos( NULL, 0,0, r.right-r.left, r.bottom - ( ((15- NumberOfSections)<9?15- NumberOfSections:9 ) * (r2.bottom-r2.top) )-r.top-12, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE );
  1170.                 GetDlgItem( IDC_TEXTECSIZE )->GetWindowRect( &r );
  1171.                 GetDlgItem( IDC_TEXTECSIZE )->SetWindowPos( NULL, r.left - r3.left, r.top -( ( (16 -NumberOfSections)<10?16-NumberOfSections:10)  * (r2.bottom-r2.top) )-r3.top-20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE );
  1172.                 GetDlgItem( IDC_KCONFIG )->GetWindowRect( &r );
  1173.                 GetDlgItem( IDC_KCONFIG )->SetWindowPos( NULL, r.left- r3.left, r.top -( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top -20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE );
  1174.                 GetDlgItem( IDC_TEXTETOTALSIZE )->GetWindowRect( &r );
  1175.                 GetDlgItem( IDC_TEXTETOTALSIZE )->SetWindowPos( NULL, r.left- r3.left, r.top -( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top -20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE );
  1176.                 GetDlgItem( IDC_KTOTAL )->GetWindowRect( &r );
  1177.                 GetDlgItem( IDC_KTOTAL )->SetWindowPos( NULL, r.left- r3.left, r.top -( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top -20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE );
  1178.                 SetWindowPos( NULL, 0,0, r3.right-r3.left, r3.bottom - ( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top+20, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE );
  1179.                     
  1180.                 // Set the dialog box value
  1181.                 CString TempLabel;                                         
  1182.                 UserConfigSize = 0L;
  1183.                 for ( i = 0 ; i <  NumberOfSections ; i++ )
  1184.                     {
  1185.                     if ( Section[i].Name.GetLength()> 0 )
  1186.                         {
  1187.                         TempLabel = ( iLanguage == LANGUAGE_FRENCH)?Section[i].FLabel : Section[i].ELabel;
  1188.                         if ( TempLabel.GetLength() > 0 )
  1189.                             {
  1190.                             GetDlgItem( 120 + i )->ShowWindow( SW_SHOW );
  1191.                             GetDlgItem( 150 + i )->ShowWindow( SW_SHOW );
  1192.                             SetDlgItemText( 120 + i, TempLabel );        // --> label
  1193.                             CheckDlgButton( 120 + i, Section[i].bSelected );        
  1194.                             if ( Section[i].bSelected )
  1195.                                 {
  1196.                                 UserConfigSize += Section[i].lSize;
  1197.                                 _ltoa( UserConfigSize, TempLabel.GetBuffer(12), 10 );
  1198.                                 TempLabel.ReleaseBuffer();
  1199.                                 TempLabel += " K";
  1200.                                 SetDlgItemText( IDC_KCONFIG, TempLabel );
  1201.                                 _ltoa( Section[i].lSize, TempLabel.GetBuffer(10), 10 );
  1202.                                 TempLabel.ReleaseBuffer();
  1203.                                 }
  1204.                             else
  1205.                                 TempLabel = "0";                         
  1206.                             TempLabel += " K";
  1207.                             SetDlgItemText( 150 + i, TempLabel );
  1208.                             }
  1209.                         }
  1210.                     }                                               
  1211.                 SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) );
  1212.                 Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL );
  1213.                 CenterDialogBox( m_hWnd );
  1214.                 BringWindowToTop();
  1215.                 if ( iLanguage == LANGUAGE_FRENCH )
  1216.                     {
  1217.                     SetDlgItemText( IDC_GROUP, "Installer... ");
  1218.                     SetDlgItemText( IDC_TEXTECSIZE, "Taille de la sΘlection:");
  1219.                     SetDlgItemText( IDC_TEXTETOTALSIZE, "Espace disponible:");
  1220.                     SetDlgItemText( IDB_CHANGEPATH, "&RΘpertoire...");
  1221.                     SetDlgItemText( IDOK, "OK" );
  1222.                     SetDlgItemText( IDCANCEL, "Aba&ndonner" );
  1223.                     }
  1224.                 _ltoa( AskForDriveSpace( GetDriveNumber( UserPath )), TempLabel.GetBuffer(15), 10 );
  1225.                 TempLabel.ReleaseBuffer();
  1226.                 TempLabel += " K";
  1227.                 SetDlgItemText( IDC_KTOTAL, TempLabel );
  1228.                 GetDlgItem( IDC_CHECK1 )->SetFocus();
  1229.                 return FALSE; 
  1230.             }
  1231.             
  1232.             // ----------------------------------------------------------
  1233.             //  WM_COMMAND:ONPATH
  1234.             //  Save the configuration and 
  1235.             //    Call the CChoice1 Dialog box
  1236.             // ----------------------------------------------------------
  1237.             void CChoice2::OnClickedChangepath()
  1238.                 {
  1239.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1240.                 register int i = 0;
  1241.                 for ( i = 0 ; i < NumberOfSections ; i++ )
  1242.                     Section[i].bSelected = IsDlgButtonChecked( 120 + i );
  1243.                 EndDialog( IDCHANGEPATH );
  1244.                 }
  1245.             
  1246.             
  1247.             // ----------------------------------------------------------
  1248.             //  WM_COMMAND:ONOK
  1249.             //  Check available disk size
  1250.             // ----------------------------------------------------------
  1251.             void CChoice2::OnOK()
  1252.                 {
  1253.                 /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1254.                 register int i = 0;
  1255.                 if ( UserConfigSize > AskForDriveSpace( GetDriveNumber( UserPath )) )
  1256.                     {
  1257.                     if ( iLanguage == LANGUAGE_FRENCH )
  1258.                         MessageBox("Il n' y a pas assez d' espace libre\nsur l' unitΘ destination pour installer\nla sΘlection que vous avez choisie.\n\nVeuillez modifier votre sΘlection ou changer de rΘpertoire."
  1259.                         , Dialog1Title, MB_OK | MB_ICONEXCLAMATION );
  1260.                     else
  1261.                         MessageBox("There is not enough free space\nto install selected files.\n\nPlease, change your selection or the destination directory."
  1262.                         , Dialog1Title, MB_OK | MB_ICONEXCLAMATION );
  1263.                     }
  1264.                 else
  1265.                     CDialog::OnOK();
  1266.                 }
  1267.             
  1268.             
  1269.             /////////////////////////////////////////////////////////// Generic //////////////////////////////////////////////////////////////////////
  1270.             // ----------------------------------------------------------
  1271.             //  WM_COMMAND:ONCHECKxx ?
  1272.             //  Check Box management
  1273.             // ----------------------------------------------------------
  1274.             void CChoice2::OnClickedCheck1()
  1275.             {
  1276.             HandleCheckBox( 1 );
  1277.             }
  1278.             void CChoice2::OnClickedCheck2()
  1279.             {
  1280.             HandleCheckBox( 2 );
  1281.             }
  1282.             void CChoice2::OnClickedCheck3()
  1283.             {
  1284.             HandleCheckBox( 3 );
  1285.             }
  1286.             void CChoice2::OnClickedCheck4()
  1287.             {
  1288.             HandleCheckBox( 4 );
  1289.             }
  1290.             void CChoice2::OnClickedCheck5()
  1291.             {
  1292.             HandleCheckBox( 5 );
  1293.             }
  1294.             void CChoice2::OnClickedCheck6()
  1295.             {
  1296.             HandleCheckBox( 6 );
  1297.             }
  1298.             void CChoice2::OnClickedCheck7()
  1299.             {
  1300.             HandleCheckBox( 7 );
  1301.             }
  1302.             void CChoice2::OnClickedCheck8()
  1303.             {
  1304.             HandleCheckBox( 8 );
  1305.             }
  1306.             void CChoice2::OnClickedCheck9()
  1307.             {
  1308.             HandleCheckBox( 9 );
  1309.             }
  1310.             void CChoice2::OnClickedCheck10()
  1311.             {
  1312.             HandleCheckBox( 10 );
  1313.             }
  1314.             void CChoice2::OnClickedCheck11()
  1315.             {
  1316.             HandleCheckBox( 11 );
  1317.             }
  1318.             void CChoice2::OnClickedCheck12()
  1319.             {
  1320.             HandleCheckBox( 12 );
  1321.             }
  1322.             void CChoice2::OnClickedCheck13()
  1323.             {
  1324.             HandleCheckBox( 13 );
  1325.             }
  1326.             void CChoice2::OnClickedCheck14()
  1327.             {
  1328.             HandleCheckBox( 14 );
  1329.             }
  1330.             void CChoice2::OnClickedCheck15()
  1331.             {
  1332.             HandleCheckBox( 15 );
  1333.             }
  1334.             
  1335.             
  1336.             void CChoice2::HandleCheckBox( int iD )
  1337.             {
  1338.             CString Temp;
  1339.             if ( IsDlgButtonChecked( 120 + iD - 1 ))
  1340.                 {
  1341.                 UserConfigSize += Section[iD - 1].lSize;
  1342.                 _ltoa( Section[iD - 1].lSize, Temp.GetBuffer( 12 ), 10 );
  1343.                 Temp.ReleaseBuffer();
  1344.                 Temp += " K";
  1345.                 SetDlgItemText( 150 + iD-1 , Temp );
  1346.                 Section[iD - 1].bSelected = TRUE;
  1347.                 }
  1348.             else
  1349.                 {
  1350.                 UserConfigSize -= Section[iD - 1].lSize;
  1351.                 SetDlgItemText(150 + iD-1, "0 K" );
  1352.                 Section[iD - 1].bSelected = FALSE;
  1353.                 }
  1354.             _ltoa( UserConfigSize, Temp.GetBuffer( 12 ), 10 );
  1355.             Temp.ReleaseBuffer();
  1356.             Temp += " K";
  1357.             SetDlgItemText( IDC_KCONFIG, Temp );
  1358.             }
  1359.             
  1360.  
  1361.             void CChoice2::OnDestroy()
  1362.             {
  1363.                 CDialog::OnDestroy();
  1364.                 ::DeleteObject( hfontDlg );
  1365.             }
  1366.             
  1367.             void CChoice1::OnDestroy()
  1368.             {
  1369.                 CDialog::OnDestroy();
  1370.                 ::DeleteObject( hfontDlg );
  1371.             }
  1372.             
  1373.             void CFirst::OnDestroy()
  1374.             {
  1375.                 CDialog::OnDestroy();
  1376.                 ::DeleteObject( hfontDlg );
  1377.             }
  1378.             
  1379.             
  1380.             
  1381. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1382. //  Local functions
  1383.  
  1384.             // ----------------------------------------------------------
  1385.             //  ExtractParameter( LPSTR, Buffer, position )
  1386.             //    Extract the Command line parameters
  1387.             // ----------------------------------------------------------
  1388.             BOOL ExtractParameter( LPSTR szCommandLine, LPSTR szBuffer, int position )
  1389.                 {
  1390.                 LPSTR szTemp;
  1391.                 LPSTR pos;
  1392.                 LPSTR szStart= "0000";
  1393.                 LPSTR szStop = "00000";
  1394.                 BOOL test1 = FALSE;
  1395.                 BOOL test2 = FALSE;
  1396.                 HANDLE h1;                                                    
  1397.                 
  1398.                 char Mask =' ' ;
  1399.                 int i;                       
  1400.                                 
  1401.                  if ( (szBuffer == (LPSTR)NULL) || (szCommandLine == (LPSTR)NULL) )
  1402.                     return FALSE;
  1403.                 h1 = GlobalAlloc( LHND,(long) (lstrlen( szCommandLine ) + 3 ) );
  1404.                 szTemp = (LPSTR)GlobalLock(h1);
  1405.                 
  1406.                 lstrcpyn( szStart, szCommandLine, 2);
  1407.                 if ( lstrcmp( szStart, " " ) == 0 )
  1408.                     test1 = TRUE;
  1409.                 lstrcpyn( szStop, szCommandLine+ lstrlen( szCommandLine) - 1 , 2 );
  1410.                 if ( lstrcmp( szStop, " ") != 0 )
  1411.                     test2 = TRUE;
  1412.                 if ( (test1) && (test2))    
  1413.                     {
  1414.                     lstrcpy( szTemp, szCommandLine+1);
  1415.                     lstrcat( szTemp, " ");
  1416.                     }
  1417.                 else
  1418.                     {
  1419.                     if ( test1 )
  1420.                         lstrcpy( szTemp, szCommandLine+1 );
  1421.                     if ( test2 )
  1422.                         {
  1423.                         lstrcpy( szTemp, szCommandLine );
  1424.                         lstrcat( szTemp, " ");
  1425.                         }
  1426.                     if ( (!test1) && (!test2))                    
  1427.                         lstrcpy( szTemp, szCommandLine);
  1428.                     }
  1429.                 i=1;
  1430.                 for ( i=1; i <= position ; i++ )
  1431.                     {
  1432.                     pos = (LPSTR)_fmemchr(szTemp, ' ', lstrlen(szTemp) );
  1433.                     if ( (i== position) && ( (pos != NULL) || ( position == 1)))
  1434.                         {       
  1435.                            lstrcpyn(szBuffer, szTemp, (pos-szTemp)+1);
  1436.                         GlobalUnlock( h1 );
  1437.                         GlobalFree( h1 );
  1438.                         return TRUE;
  1439.                         }                                                                                           
  1440.                     else
  1441.                           {
  1442.                           if ( pos != NULL )
  1443.                                lstrcpy( szTemp, _fstrstr(szTemp," ")+1);
  1444.                            else
  1445.                             lstrcpy( szTemp, "");
  1446.                         }
  1447.                      }
  1448.                   lstrcpy( szBuffer, "");
  1449.                   GlobalUnlock( h1 );
  1450.                   GlobalFree( h1 );
  1451.                   return FALSE;
  1452.                   }
  1453.                         
  1454.                                             
  1455. //////////////////////////////////////////////// END OF THIS FILE ////////////////////////////////////////////////////////////////
  1456.                                 
  1457.